//
//  MSCollectionBaseCell.m
//  MSJD
//
//  Created by xiangbo on 2018/10/20.
//  Copyright © 2018 xiangbo. All rights reserved.
//

#import "MSCollectionBaseCell.h"

@implementation MSCollectionBaseCell

- (void)setupTemplateDetailData:(MSFoodDetailData *)detailData{
    
}

- (void)setModelData:(id)modelData{
    
}
@end

@implementation MSTypeACollectionCell

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.showView = [[MSTypeADetailView alloc] init];
        [self.contentView addSubview:self.showView];
        
        [self.showView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView);
        }];
    }
    return self;
}

- (void)setModelData:(id)modelData{
    super.modelData = modelData;
    self.showView.detailData = modelData;
}

@end

@implementation MSTypeBCollectionCell

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.showView = [[MSTypeBDetailView alloc] init];
        [self.contentView addSubview:self.showView];
        
        [self.showView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView);
        }];
    }
    return self;
}

- (void)setModelData:(id)modelData{
    super.modelData = modelData;
    self.showView.detailData = modelData;
}

@end

/** 带评分collectionViewCell */
@implementation MSVimgCollectionCell

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.showView = [[MSVImgDetailView alloc] init];
        [self.contentView addSubview:self.showView];
        
        [self.showView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView);
        }];
    }
    return self;
}

- (void)setModelData:(id)modelData{
    super.modelData = modelData;
    self.showView.detailData = modelData;
}

@end

@implementation MSPhotosCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.image = [[UIImageView alloc] init];
        [self.image setImage:[UIImage imageWithColor:MSPlaceholderColor]];
        [self.contentView addSubview:self.image];
        self.image.layer.cornerRadius = 4.f;
        self.image.clipsToBounds = YES;
        
        [self.image mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self);
        }];
    }
    return self;
}


- (void)setModelData:(id)modelData{
    NSString *imgUrl = nil;
    if ([modelData isKindOfClass:MSFoodContentModel.class]) {
        imgUrl = ((MSFoodContentModel *)modelData).cover;
    }
    [self.image setImageWithURL:[NSURL URLWithString:imgUrl] placeholder:MSPlaceholderImg];
}
@end
